package com.lsn.watermall.entity;

import com.lsn.watermall.exception.BaseErrorInfo;
import com.lsn.watermall.exception.ErrorInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private String retCode;
    private String retMsg;
    private Object body;

    public static Result ok() {
        Result result = new Result();
        result.setRetCode(ErrorInfo.SUC0000.getRetCode());
        result.setRetMsg(ErrorInfo.SUC0000.getRetMsg());
        result.setBody(null);
        return result;
    }

    public static Result ok(Object body) {
        Result result = new Result();
        result.setRetCode(ErrorInfo.SUC0000.getRetCode());
        result.setRetMsg(ErrorInfo.SUC0000.getRetMsg());
        result.setBody(body);
        return result;
    }
    public static Result error(BaseErrorInfo baseErrorInfo) {
        Result result = new Result();
        result.setRetCode(baseErrorInfo.getRetCode());
        result.setRetMsg(baseErrorInfo.getRetMsg());
        result.setBody(null);
        return result;
    }

    public static Result error(BaseErrorInfo baseErrorInfo,Object object) {
        Result result = new Result();
        result.setRetCode(baseErrorInfo.getRetCode());
        result.setRetMsg(baseErrorInfo.getRetMsg());
        result.setBody(object);
        return result;
    }

    public static Result error(String retCode, String retMsg) {
        Result result = new Result();
        result.setRetCode(retCode);
        result.setRetMsg(retMsg);
        result.setBody(null);
        return result;
    }
}
